var mongoUrl = 'mongodb://localhost:27017/proxy';
var mongo = require('./mongo');
mongo.connect(mongoUrl, function(){
    console.log('Connected to mongo at: ' + mongoUrl);
});

module.exports = {
    logRequest:function(data, callback){
        var coll = mongo.collection("requests");
        coll.insert(data.headers, function(err, result){
	    callback(err, result);
	});
    },
    logResponse:function(host, body, callback){
	console.log(host);
	console.log(body);
	var coll = mongo.collection('response');
	coll.insert({'host': host, 'body': body}, function(err, result){
	    callback(err, result);
	});
    }
};